/*
Copyright (c) 2007, EffectiveUI, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of the EffectiveUI nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@ignore
*/
package com.effectiveui.frameworks.jest {
	
	/**
	 * 
	 * Gestures contains constants describing the possible 
	 * direction componets of a gesture. 
	 * 
	 * <p>
	 * Three different ways of thinking about gesture 
	 * components are supported:
	 * <ul>
	 * <li>As cardinal and ordinal points on a compass, e.g. North, East, South West, etc...</li>
	 * <li>As relative directions, e.g. Up, Down, Up Right, etc..</li>
  	 * <li>As approximate locations on a clock face, e.g. One O'Clock, Ten O'Clock, etc...</li>
  	 * </ul>
	 * 
	 */	
	public class Gestures {
		
		public static const N:String				= '1';
		public static const S:String				= '2';
		public static const E:String				= '3';
		public static const W:String				= '4';
		public static const NW:String				= '5';
		public static const NE:String				= '6';
		public static const SW:String				= '7';
		public static const SE:String				= '8';
		
		//aliases
		public static const UP:String				= N;
		public static const DOWN:String				= S;
		public static const RIGHT:String			= E;
		public static const LEFT:String				= W;
		public static const UP_RIGHT:String			= NE;
		public static const UP_LEFT:String			= NW;
		public static const DOWN_RIGHT:String		= SE;
		public static const DOWN_LEFT:String		= SW;
		
		
		public static const ONE_O_CLOCK:String		= N;
		public static const SIX_O_CLOCK:String		= S;
		public static const THREE_O_CLOCK:String	= E;
		public static const NINE_O_CLOCK:String		= W;
		public static const TWO_O_CLOCK:String		= NE;
		public static const TEN_O_CLOCK:String		= NW;
		public static const FOUR_O_CLOCK:String		= SE;
		public static const SEVEN_O_CLOCK:String	= SW;

		
		public static const gesturesAsCompass:Object
			= {'1':'N', '2':'S', '3':'E', '4':'W', '5':'NW', '6':'NE', '7':'SW', '8':'SE'}

		public static const gesturesAsRelativeDirections:Object
			= {'1':'Up', '2':'Down', '3':'Right', '4':'Left', '5':'Up Left', '6':'Up Right', '7':'Down Left', '8':'Down Right'}
		
		public static const gesturesAsClock:Object
			= {'1':'1 O\'Clock', '2':'6 O\'Clock', '3':'3 O\'Clock', '4':'9 O\'Clock', '5':'10 O\'Clock', '6':'2 O\'Clock', '7':'7 O\'Clock', '8':'4 O\'Clock'}
		
		/**
		 * Describes an array of gesture components as a compass points.
		 * 
		 * @param gestures An array of gestures (derived from the constants in this class)
		 * @return a human readable description of a sequence of gesture components.
		 * 
		 */		
		public static function describeAsCompass(gestures:Array):String {
			var desc:String = ''
			for each (var gesture:String in gestures) {
				desc = desc.concat(gesturesAsCompass[gesture]);
			}
			return desc;
		}

		/**
		 * Describes an array of gesture components as locations on a clock.
		 * 
		 * @param gestures An array of gestures (derived from the constants in this class)
		 * @return a human readable description of a sequence of gesture components.
		 * 
		 */		
		public static function describeAsClock(gestures:Array):String {
			var desc:String = ''
			for each (var gesture:String in gestures) {
				desc = desc.concat(gesturesAsClock[gesture]);
			}
			return desc;
		}

		/**
		 * Describes an array of gesture components as relative directions.
		 * 
		 * @param gestures An array of gestures (derived from the constants in this class)
		 * @return a human readable description of a sequence of gesture components.
		 * 
		 */		
		public static function describeAsRelativeDirections(gestures:Array):String {
			var desc:String = ''
			for each (var gesture:String in gestures) {
				desc = desc.concat(gesturesAsRelativeDirections[gesture]);
			}
			return desc;
		}
	}
}